<html>
<head>
<title>修改密码</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>


</head>
<body>
	<div id="psw_panel" class="easyui-panel" title="修改密码" style="width:100%;height:400px;padding:10px;">
		<table cellpadding="5" style="margin:0 auto;">
    		<tr>
    			<td>用户名:</td>
    			<td><input id="username" class="easyui-textbox" type="text" name="username" data-options="readonly:true"></input></td>
    		</tr>
    		<tr>
    			<td>原密码:</td>
    			<td><input id="oldpassword" class="easyui-textbox" type="password" name="oldpassword" data-options="required:true"></input></td>
    		</tr>
    		
    		<tr>
    			<td>新密码:</td>
    			<td><input id="password" class="easyui-textbox" type="password" name="password" data-options="required:true"></input></td>
    		</tr>
    		<tr>
    			<td>密码确认:</td>
    			<td>
    				<input id="rpassword" class="easyui-textbox" type="password" name="rpassword" data-options="required:true"></input>
    			</td>
    		</tr>
    	</table>

	    <div style="text-align:center;padding:5px;margin-top:10px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
	    	<a href="javascript:void(0)" style="margin-left:50px" class="easyui-linkbutton" onclick="clearForm()">清空</a>
	    </div>
	</div>

</body>
<script>
$(document).ready(function(){
	$.parser.parse("#psw_panel");
	pswinit();
});
function pswinit(){
	//alert(userSession.username);
	$('#username').textbox('setValue',userSession.username);
	$('#oldpassword').textbox().next('span').find('input').focus();
}
function submitForm(){
	var datastring = '{"username":"'+userSession.username+'","oldpassword":"'+ $("#oldpassword").textbox('getValue')   +'","password":"'+$("#password").textbox('getValue')+
		'","rpassword":"'+ $("#rpassword").textbox('getValue') + '"}';
	if($("#password").textbox('getValue') != $("#rpassword").textbox('getValue')){
		$.messager.alert('警告','两次输入密码不一致!','warning');
		return;
	}
	$.ajax({
		type:"post",
		contentType: "application/json;charset=UTF-8",
		url: "/testdemo/userpsw.do?",
		async:false,
		data:datastring,
     	dataType:"json",
        success: function(msg) {    //数据提交成功时返回数据

        	$.messager.alert('通知',msg.desc,'info');
        	$.ajax({
    			type:"GET",
    			contentType: "application/json;charset=UTF-8",
    			url: "/testdemo/logout.do?",
    			async:false,
    	     	dataType:"text",
    	        success: function(msg) {    //数据提交成功时返回数据

    	        	location.reload();
    								
    				
    	        },
    	        error : function(e){
    	            alert(e.status);
    	            alert(e.responseText);
    	        }

    		});			
			
        },
        error : function(e){
            alert(e.status);
            alert(e.responseText);
        }

	});
}

function clearForm(){
	//$('#ff').form('clear');
	$("#username").textbox('clear');
	$("#oldpassword").textbox('clear');
	$("#password").textbox('clear');
	$("#rpassword").textbox('clear');
}
</script>
</html>